home *** CD-ROM | disk | FTP | other *** search
- package hhapplet;
-
- import java.applet.Applet;
- import java.awt.BorderLayout;
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.LayoutManager;
- import java.awt.List;
- import java.awt.Panel;
- import java.awt.TextField;
- import java.net.MalformedURLException;
- import java.util.Vector;
-
- public class IndexPane extends Panel implements DialogDoneTarget {
- protected Applet m_applet;
- protected Vector m_vSecondaryEntries = new Vector();
- protected List m_list = new List();
- protected TextField m_tfEdit = new TextField();
- protected Button m_btnDisplay = new Button("Display");
- protected IndexSecondaryDialog m_dlgSecondary;
- protected int m_nSelectedIndex = -1;
- protected boolean m_bIsIE4;
- protected boolean m_bIsNSWin16;
- protected boolean m_bIsNSWin32;
- protected boolean m_bIsIE3;
- private LayoutManager m_layout;
-
- public boolean gotFocus(Event var1, Object var2) {
- if (var1.target != this.m_tfEdit && var1.target != this.m_list && var1.target != this.m_btnDisplay) {
- this.m_tfEdit.requestFocus();
- }
-
- return true;
- }
-
- public void dialogDone() {
- this.m_dlgSecondary = null;
- this.m_tfEdit.requestFocus();
- }
-
- public IndexPane(Applet var1) {
- this.m_applet = var1;
- this.m_layout = new BorderLayout(5, 5);
- ((Container)this).setLayout(this.m_layout);
- this.m_list.setBackground(Color.white);
-
- try {
- if (System.getProperty("java.vendor").startsWith("Netscape")) {
- if (System.getProperty("os.name").startsWith("16-bit Windows")) {
- this.m_bIsNSWin16 = true;
- } else if (System.getProperty("os.name").startsWith("Windows")) {
- this.m_bIsNSWin32 = true;
- }
- } else if (System.getProperty("java.vendor").startsWith("Microsoft")) {
- if (System.getProperty("java.version").startsWith("1.1")) {
- this.m_bIsIE4 = true;
- } else {
- this.m_bIsIE3 = true;
- }
- }
- } finally {
- ;
- }
-
- int var2 = WebHelp.GetFontSize();
- this.m_list.setFont(new Font(WebHelp.GetFontName(), 0, var2));
- this.m_tfEdit.setFont(new Font(WebHelp.GetFontName(), 0, var2));
- ((Container)this).add("North", this.m_tfEdit);
- ((Container)this).add("Center", this.m_list);
- ((Container)this).add("South", this.m_btnDisplay);
- this.m_tfEdit.requestFocus();
- }
-
- public void add(String var1, Vector var2) {
- this.m_list.addItem(var1);
- this.m_vSecondaryEntries.addElement(var2);
- }
-
- public List getList() {
- return this.m_list;
- }
-
- public boolean keyUp(Event var1, int var2) {
- if (this.m_bIsNSWin16) {
- var2 &= 255;
- }
-
- if ((this.m_bIsIE4 || this.m_bIsIE3 || this.m_bIsNSWin32) && var1.key == 10) {
- this.action(var1, var1.target);
- return true;
- } else {
- boolean var3 = super.keyUp(var1, var2);
- if (var2 >= 32 && var2 <= 126) {
- try {
- this.textChanged();
- if (var1.target == this.m_tfEdit) {
- this.m_tfEdit.requestFocus();
- }
- } finally {
- ;
- }
- }
-
- return var3;
- }
- }
-
- protected void gotoSelectedIndex() {
- int var1 = this.m_list.getSelectedIndex();
- if (var1 != -1) {
- if (((Vector)this.m_vSecondaryEntries.elementAt(var1)).size() != 1) {
- if (this.m_dlgSecondary == null) {
- this.m_dlgSecondary = new IndexSecondaryDialog(this.m_applet, (Vector)this.m_vSecondaryEntries.elementAt(var1), this);
- this.m_dlgSecondary.show();
- this.m_dlgSecondary.requestFocus();
- }
-
- } else {
- IndexSecondaryEntry var2 = (IndexSecondaryEntry)((Vector)this.m_vSecondaryEntries.elementAt(var1)).elementAt(0);
- if (var2.see_also != null) {
- for(int var3 = 0; var3 < this.m_vSecondaryEntries.size(); ++var3) {
- if (((Vector)this.m_vSecondaryEntries.elementAt(var3)).size() == 1) {
- IndexSecondaryEntry var4 = (IndexSecondaryEntry)((Vector)this.m_vSecondaryEntries.elementAt(var3)).elementAt(0);
- if (var4.name.equals(var2.see_also)) {
- this.m_list.select(var3);
- if (this.m_list.getVisibleIndex() != var3) {
- this.m_list.makeVisible(var3);
- }
-
- this.gotoSelectedIndex();
- return;
- }
- }
- }
- } else {
- try {
- if (var2.frame != null) {
- this.m_applet.getAppletContext().showDocument(URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var2.local, var2.url), var2.frame);
- } else {
- this.m_applet.getAppletContext().showDocument(URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var2.local, var2.url), "_self");
- }
- } catch (MalformedURLException var5) {
- }
- }
-
- this.m_tfEdit.requestFocus();
- }
- }
- }
-
- protected void finalize() throws Throwable {
- this.m_list.clear();
- super.finalize();
- }
-
- public boolean action(Event var1, Object var2) {
- this.gotoSelectedIndex();
- return true;
- }
-
- public boolean handleEvent(Event var1) {
- if (this.m_bIsIE4 && var1.id == 1001 && var1.target == this.m_tfEdit) {
- return true;
- } else {
- if (var1.target == this.m_list && var1.id == 701 && this.m_list.getSelectedIndex() != this.m_nSelectedIndex) {
- String var2 = this.m_list.getSelectedItem();
- this.m_nSelectedIndex = this.m_list.getSelectedIndex();
- if (var2 != null) {
- this.m_tfEdit.setText(var2);
- this.m_applet.showStatus(var2);
- this.m_list.requestFocus();
- }
- }
-
- return super.handleEvent(var1);
- }
- }
-
- public void textChanged() {
- String var1 = this.m_tfEdit.getText().toUpperCase();
- int var2 = var1.length();
- if (var2 != 0) {
- for(int var3 = 0; var3 < this.m_list.countItems(); ++var3) {
- String var4 = this.m_list.getItem(var3).toUpperCase();
- if (var4.startsWith(var1)) {
- try {
- this.m_list.deselect(this.m_list.getSelectedIndex());
- } catch (ArrayIndexOutOfBoundsException var6) {
- }
-
- this.m_list.select(var3);
- this.m_nSelectedIndex = var3;
- this.m_applet.showStatus(this.m_list.getSelectedItem());
- int var5 = this.m_list.getVisibleIndex();
- if (var5 > var3 || var5 < var3 + 10) {
- this.m_list.makeVisible(var3);
- }
-
- return;
- }
- }
-
- }
- }
- }
-